
import 'package:flutter/material.dart';
import 'package:flutter_sample/src/log_util.dart';
import 'package:go_router/go_router.dart';
import 'package:logger/logger.dart';

class LayoutBuilderPage extends StatefulWidget {
  const LayoutBuilderPage({super.key});

  @override
  State<LayoutBuilderPage> createState() => _LayoutBuilderPageState();
}

class _LayoutBuilderPageState extends State<LayoutBuilderPage> {

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("LayoutBuilder"),
        centerTitle: true,
        leading: IconButton(onPressed: () {
          context.pop();
        }, icon: Icon(Icons.arrow_back_ios_rounded)),
      ),
      body: LayoutBuilder(builder: (context, constraints) {
        logger.i("maxWidth: ${constraints.maxWidth}  maxHeight: ${constraints.maxHeight}  ");
        logger.i("minWidth: ${constraints.minWidth}  minHeight: ${constraints.minHeight}  ");
        return AspectRatio(
          aspectRatio: 4 / 3,
          child: Container(
            width: constraints.maxWidth,
            height: constraints.maxHeight,
            color: Colors.red,
          ),
        );

      }),
    );
  }
}
